<?php

namespace app\home\model;
use think\Db;
use think\Model;
class MemberloginModel extends Model
{
    public function doMemberLogin($data){
        $old = Db::name("member")->where('mobile',$data["username"])->find();
        if(!empty($old)){
            $old["mobile"] = $data["username"];
            $comparePasswordResult = password_verify($data["password"], $old["pass_word"]);
            $hookParam = [
                'user' =>$data,
                'compare_password_result' =>$comparePasswordResult
            ];
            hook_one("user_login_start", $hookParam);
            if($comparePasswordResult){
                session('user', $old);
                return 0;
            }
            return 1;
        }
        $hookParam = [
            'user'                    => $data,
            'compare_password_result' => false
        ];
        hook_one("user_login_start", $hookParam);
        return 2;
    }
}

